package logic

import (
	"context"
	"errors"
	"regi-sys/model"

	"regi-sys/userrpc/internal/svc"
	"regi-sys/userrpc/userrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserDelLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserDelLogic {
	return &UserDelLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 用户删除
func (l *UserDelLogic) UserDel(in *userrpc.UserDelRequest) (*userrpc.UserDelResponse, error) {
	// todo: add your logic here and delete this line

	var user model.User
	err := user.UserDelById(model.DB, in.UserId)
	if err != nil {
		return nil, errors.New("用户删除失败")
	}

	return &userrpc.UserDelResponse{}, nil
}
